﻿using EquipmentAlarmSystem.Service.Library;
using Microsoft.AspNetCore.Mvc;
using System.Text.Encodings.Web;
using System.Text.Json;

namespace EquipmentAlarmSystem.Controllers;

/// <summary>
/// 系统配置
/// </summary>
[ApiController]
[Route("[controller]/[action]")]
public class ConfigureController : Controller
{
    private readonly ILogger<ConfigureController> _logger;

    public ConfigureController(ILogger<ConfigureController> logger)
    {
        _logger = logger;
    }

    /// <summary>
    /// 获取配置文件
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    public string GetConfigure()
    {
        return JsonSerializer.Serialize(Basics.Config, new JsonSerializerOptions()
        {
            Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
        });
    }

    /// <summary>
    /// 修改配置文件
    /// </summary>
    /// <param name="configure"></param>
    /// <returns></returns>
    //[HttpPost]
    //public string ModifyConfigure(Configure configure)
    //{
    //    Basics.Config = configure;

    //    return Basics.WriteConfig();
    //}
}
